package com.jiuzhi.app.controller;

import java.util.List;

import com.jiuzhi.app.domain.NcpOwnerReg;
import com.jiuzhi.app.service.INcpOwnerRegService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jiuzhi.common.annotation.Log;
import com.jiuzhi.common.enums.BusinessType;
import com.jiuzhi.common.core.controller.BaseController;
import com.jiuzhi.common.core.domain.AjaxResult;
import com.jiuzhi.common.utils.poi.ExcelUtil;
import com.jiuzhi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author jiuzhi
 * @date 2020-02-15
 */
@Controller
@RequestMapping("/system/reg")
public class NcpOwnerRegController extends BaseController
{
    private String prefix = "system/reg";

    @Autowired
    private INcpOwnerRegService ncpOwnerRegService;


    @GetMapping()
    public String reg()
    {
        return prefix + "/reg";
    }

    /**
     * 查询【请填写功能名称】列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(NcpOwnerReg ncpOwnerReg)
    {
        startPage();
        List<NcpOwnerReg> list = ncpOwnerRegService.selectNcpOwnerRegList(ncpOwnerReg);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */

    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(NcpOwnerReg ncpOwnerReg)
    {
        List<NcpOwnerReg> list = ncpOwnerRegService.selectNcpOwnerRegList(ncpOwnerReg);
        ExcelUtil<NcpOwnerReg> util = new ExcelUtil<NcpOwnerReg>(NcpOwnerReg.class);
        return util.exportExcel(list, "reg");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */

    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(NcpOwnerReg ncpOwnerReg)
    {
        return toAjax(ncpOwnerRegService.insertNcpOwnerReg(ncpOwnerReg));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        NcpOwnerReg ncpOwnerReg = ncpOwnerRegService.selectNcpOwnerRegById(id);
        mmap.put("ncpOwnerReg", ncpOwnerReg);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */

    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(NcpOwnerReg ncpOwnerReg)
    {
        return toAjax(ncpOwnerRegService.updateNcpOwnerReg(ncpOwnerReg));
    }

    /**
     * 删除【请填写功能名称】
     */

    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ncpOwnerRegService.deleteNcpOwnerRegByIds(ids));
    }
}
